﻿namespace RockPaperScissors.Web.Utility.Tests
{
    using GravityWorks.RockPaperScissors.Toolkit;
    using NUnit.Framework;
    using RockPaperScissors.Core;
    using RockPaperScissors.Web.Utility.Tests.Mocks;
    
    [TestFixture]
    public class GameLogTests
    {
        [Test]
        public void Should_Not_Be_Able_To_Modify_The_Game_Log()
        {
            RuleSet ruleSet = new RuleSet().CreateRuleSet(true, true, true, true, 3);
            GameLog gameLog = new GameLog().CreateGameLogWithNoDynamiteLeftForTeam("team1", 3);

            IPlayer firstTeam = new Mocks.MockCheatLogPlayer();
            IPlayer secondTeam = new MockPlayer();
            MoveType firstTeamMove = CompeteHelper.GetShot(firstTeam, gameLog, ruleSet, 1);
            MoveType secondTeamMove = MoveType.Paper;

            string firstTeamName = "team1";
            string secondTeamName = "team2";
            MatchResult result = CompeteHelper.CalculateWinner(firstTeamName, firstTeamMove, secondTeamName, secondTeamMove, ruleSet, gameLog);

            Assert.IsTrue(result.WinnerTeamName == "team2");
        }

        [Test]
        public void Should_Still_Process_Shot_When_GameLog_Is_Null()
        {
            RuleSet ruleSet = new RuleSet().CreateRuleSet(true, true, true, true, 3);
            IPlayer team = new ExceptionPlayer();
            MoveType move = CompeteHelper.GetShot(team, null, ruleSet, 1);

            Assert.IsTrue(move == MoveType.None);
        }
    }
}
